package persistence;

import java.util.ArrayList;
import java.util.List;

import main.BAKAServerPlugin;

public class CHandlerManager {
	List<ICommandHandler> commander;
	List<IEventHandler> eventer;

	public CHandlerManager() {
		commander = new ArrayList<ICommandHandler>();
		eventer = new ArrayList<IEventHandler>();
	}

	public boolean AddCommandHandler(ICommandHandler handler) {
		for (ICommandHandler h : commander) {
			if (h.equals(handler))
				return false;
		}
		
		commander.add(handler);
		for(String s : handler.getCommandBindStrings())
		{
			BAKAServerPlugin.instance.getCommand(s).setExecutor(handler.getExecutor());
		}
		
		return true;
	}

	public boolean AddEventHandler(IEventHandler handler) {
		for (IEventHandler h : eventer) {
			if (h.equals(handler))
				return false;
		}
		eventer.add(handler);
		return true;
	}

}
